package reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class Test {
    public static void main(String[] args) throws Exception {
        Class<?> c = Class.forName("reflect.Person");
        Object o = c.newInstance();
        Method[] methods = c.getMethods();
        for (Method method : methods) {
            if (method.getParameterCount() == 0 && method.getModifiers() == Modifier.PUBLIC) {
                method.invoke(o);
            }
        }
    }
}
